package cl.ips.gob.controllers;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.def.TaskController;
import org.jbpm.taskmgmt.def.TaskControllerHandler;
import org.jbpm.taskmgmt.exe.TaskInstance;

public class GestionNormativaCO extends TaskController implements TaskControllerHandler{

	@Override
	public void initializeTaskVariables(TaskInstance taskInstance,
			ContextInstance contextInstance, Token token) {
		
		System.out.println("Ingresa al método initializeTaskVariables de Gestion Normativa");
		SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
		String formattedDate = formatter.format(new Date());
		contextInstance.setVariable("entradaNodoGestionNormativa", formattedDate);
		
		taskInstance.start();
		
	}

	@Override
	public void submitTaskVariables(TaskInstance taskInstance,
			ContextInstance contextInstance, Token token) {
	
		System.out.println("Ingresa al método de salida submitTaskVariables");
		SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
		String formattedDate = formatter.format(new Date());
		contextInstance.setVariable("salidaNodoGestionNormativa", formattedDate);
	}

}
